package com.jiazhong.shixi.book.controller;

import com.jiazhong.shixi.book.bean.ShoppingCart;
import com.jiazhong.shixi.book.mapper.ShoppingCartMapper;
import com.jiazhong.shixi.book.uilt.JsonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/shopping")


public class ShoppingCartController {
    @Resource
    private ShoppingCartMapper shoppingCartMapper;

    //查看购物车
    @RequestMapping("/shopping_look")
    public JsonResult shopping_look(String user_id) {
        List<ShoppingCart> chopping = shoppingCartMapper.shopping_look(user_id);
        JsonResult result = new JsonResult(true,201,chopping,"");
        return result;
    }

    //添加购物车
    @RequestMapping("/shopping_zhuce")
    public  JsonResult shopping_zhuce(ShoppingCart sc) {
        shoppingCartMapper.add(sc);
        JsonResult result = new JsonResult(true,201,"success","");
        return result;

    }
    //更新购物车数量
    @RequestMapping("/shopping_up")
    public JsonResult shopping_up(ShoppingCart sc) {
        shoppingCartMapper.update(sc);
        JsonResult result = new JsonResult(true,201,"success","");
        return result;
    }

    //逻辑删除
    @RequestMapping("/shopping_shan")
    public JsonResult shan(ShoppingCart sc) {
        shoppingCartMapper.shan(sc);
        JsonResult result = new JsonResult(true,201,"success","");
        return result;
    }

    //逻辑全删
    @RequestMapping("/shopping_all")
    public JsonResult all(ShoppingCart sc) {
        shoppingCartMapper.all(sc);
        JsonResult result = new JsonResult(true,201,"success","");
        return result;
    }
}
